use away_mq_client::client::Client;
use away_mq_core::message::*;

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let mut client = Client::new();
    client.connect("127.0.0.1:8080", "admin", "123456")?;
    client.subscribe("pub", &|payload| {
        println!("{:?}", payload);
    });

    loop {
        let mut a = String::new();
        std::io::stdin().read_line(&mut a)?;
        client.publish(PayloadMessage {
            method: "b".to_owned(),
            data: a,
        });
    }
}
